package br.com.dispositivosmoveis.acompanhamentodeconta.service;

import java.util.Set;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import br.com.dispositivosmoveis.acompanhamentodeconta.abstracts.SharedPreferencesService;

public class SharedPreferencesServiceImpl implements SharedPreferencesService {
	
	private final SharedPreferences prefs;
	final static String APP_PREFS = "app_prefs";
	
	public SharedPreferencesServiceImpl(Context ctx)
	{
		prefs = ctx.getSharedPreferences(APP_PREFS, 0);
	}
	
	@Override
	public String obterValor(String key) {
		return prefs.getString(key, null);
	}
	
	@Override
	public Set<String> obterValorStringSet(String key) {
		return prefs.getStringSet(key, null);
	}

	@Override
	public void setarValor(String key, String value) {
		Editor editor = prefs.edit();
	    editor.putString(key, value);
	    editor.commit();
	}
	
	@Override
	public void setarValor(String key, Long value) {
		Editor editor = prefs.edit();
	    editor.putLong(key, value);
	    editor.commit();
	}
	
	@Override
	public void setarValor(String key, Integer value) {
		Editor editor = prefs.edit();
	    editor.putInt(key, value);
	    editor.commit();
	}
	
	@Override
	public void setarValorStringSet(String key, Set<String> value) {
		Editor editor = prefs.edit();
	    editor.putStringSet(key, value);
	    editor.commit();
	}

}
